package controller.listeners.posprocessingDups;



import model.PosProcessingDuplicatedModel;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import business.ViewLogger;

import view.PosProcessingDuplicatedView;

public class DuplicatedIdsSelectionListener implements Listener {


	private PosProcessingDuplicatedView _view;
	private PosProcessingDuplicatedModel _model;
	
			public DuplicatedIdsSelectionListener(PosProcessingDuplicatedView view,
					PosProcessingDuplicatedModel model) {
				this._model = model;
				this._view = view;
			}
			
			@Override
			public void handleEvent(Event event) {
				 
				String idStr = _view.getSelectedIdCodeCorpFromDuplicatedTable();
				
				try {
					Integer id = Integer.parseInt(idStr);
					_model.set_selected_idcodecorp(id);
					_view.setIDNOS(_model.get_idnos());
					_view.setCentersOfPosCodeCorps(_model.get_posCodeCorps());
					_view.setCentersOfIDNO(_model.get_corpsOfIdno());
					
				} catch (NumberFormatException e) {
					ViewLogger.getInstance().error("El identificador seleccionado no es un numero correcto");
				}
				
				
							
			}
		}